﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using BookItems.Core;

namespace BookItems.Site
{
	public partial class UserList : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{

		}

		public string GetUserListHtml()
		{
			BookableItem bookableItem = SessionManager.Shared.BookableItem;
            bookableItem.Refresh(); // Make sure we have the latest user details

			StringBuilder html = new StringBuilder();

			foreach (User user in bookableItem.Users)
			{
				html.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td><a href=\"mailto:{3}\">{3}</a></td><td><a href=\"tel://{4}\">{4}</a></td><td><a href=\"tel://{5}\">{5}</a></td></tr>",
					HttpUtility.HtmlEncode(user.Username),
					HttpUtility.HtmlEncode(user.FirstName),
					HttpUtility.HtmlEncode(user.LastName),
					HttpUtility.HtmlEncode(user.EmailAddress),
					HttpUtility.HtmlEncode(user.PhoneNumber),
					HttpUtility.HtmlEncode(user.MobileNumber)
					);
			}

			return html.ToString();
		}
	}
}
